import { ipcMain } from 'electron';
import SerializationController from '../controller/SerializationController';

/**
 * 注册 JSON 序列化相关的 IPC 事件处理器
 */
export function setupSerializationHandlers() {
  ipcMain.handle('serialization:save', async (event, data) => {
    return await SerializationController.saveJSON(event, data);
  });

  ipcMain.handle('serialization:load', async (event) => {
    return await SerializationController.loadJSON(event);
  });

  return () => {
    ipcMain.removeAllListeners('serialization:save');
    ipcMain.removeAllListeners('serialization:load');
  };
}
